#!/bin/bash
m=`date +%m`
d=`date +%d`
y=`date +%Y`
h=`date +%H`
min=`date +%M`
filename=$y-$m-$d-$h-$min
echo "$filename"
echo "please enter your dir: "
read path1
if [ ! -d "$path1" ];then
   echo "ERROR: No such file or dir"
else
headname=`basename $path1`
echo "$headname"
fi
echo "please enter your backup file path:"
read path2
if [ ! -d "$path2" ];then
   echo "ERROR:No such file or dir"
else
   tar zcvf $path2/$headname$filename.tgz $path1
fi

if [ $? -eq 0 ];then
   echo "bakeup complete!"
else
   echo "please enter your right dir:"
fi
echo "the following is the backup file: "
find / -name '*.tgz'
echo "please input the filename you want check: "
read filename
if [ ! -d "$filename" ];then
tar tvf $filename
#tmp1=2
else
echo "ERORR:No such file!!!"
fi
